package com.aerospace.webapi.controller;


import com.aerospace.webapi.domain.user.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RESTFullController {

    @RequestMapping("/boot/user/{id}")
    public Object returnR(@PathVariable("id") Integer id){
        User user = new User();
        user.setId(id);
        user.setName("张三丰");
        return user;
    }

    @RequestMapping("/boot/user/{id}/{name}")
    public Object returnR(@PathVariable("id") Integer id,@PathVariable("name") String name){
        User user = new User();
        user.setId(id);
        user.setName("张三丰");
        return user;
    }
    @RequestMapping("/boot/{name}/user/{id}")
    public Object returnR1(@PathVariable("id") Integer id,@PathVariable("name") String name){
        User user = new User();
        user.setId(id);
        user.setName("张三丰");
        return user;
    }
    //交换位置时如果两个都是同一类型，不能正常使用，这是模糊不清的模棱两可的
    //不能在同时有/boot/user/{age}/{id},有歧义
    @RequestMapping("/boot/user/{id}/{age}")
    public Object returnR1(@PathVariable("id") Integer id,@PathVariable("age") int age){
        User user = new User();
        user.setId(id);
        user.setName("张三丰");
        user.setAge(age);
        return user;
    }

}
